#ifndef _LIBCFG_H_
#define _LIBCFG_H_

/*
 * Simple configure file parser.
 *
 * Configure file format:
 *
 *   - leading blanks were ignored
 *   - leading '#' start comments line, comments were ignored
 *   - option lines should be in the form of "name = value", blanks between both
 *     side of '=' was optional
 *   - single and double quote can be used in "name" and "value"
 *   - backslash escape was supported in "name" and "value"
 */

enum {
  CFG_STR,
  CFG_NUM,
};

typedef struct _cfg_item {
  char *name;  /* name of the config option */
  int type;    /* config option value type: string or number? */
  void *value; /* pointer to the variable which will save the config value */
} cfg_item_t;

/*
 * cfg_parse - parse a cofig file
 *
 * @file name of the config file to be parsed
 * @items config options supported, should be %NULL terminated
 *
 * return 0 on success, -1 on error
 */
int cfg_parse(char *file, cfg_item_t *items);

#endif
